import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int n = s.length();
        int[][] dp = new int[n][n];
        for(int i = n-1; i >= 0; i--) {
            for(int j = i; j < n; j++) {
                if(i == j) {
                    dp[i][j] = 1;
                } else {
                    char ch1 = s.charAt(i);
                    char ch2 = s.charAt(j);
                    if(ch1 == ch2) {
                        dp[i][j] = dp[i+1][j-1] + 2;
                    } else {
                        dp[i][j] = Math.max(dp[i+1][j], dp[i][j-1]);
                    }
                }
            }
        }
        System.out.println(dp[0][n-1]);
    }

    /*public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        Map<Character, Integer> hash = new HashMap<>();
        for(int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            hash.put(ch, hash.getOrDefault(ch, 0) + 1);
            //hash[ch - 'a']++;
        }
        //Set<Map.Entry<Character, Integer>> set = hash.entrySet();
        int ret = 0;
        for(Map.Entry<Character, Integer> set : hash.entrySet()) {
            int count = set.getValue();
            if(count >= 2) {
                ret += (count / 2) * 2;
                set.setValue(count % 2);
            }
        }
        if(hash.containsValue(1)) {
            ret++;
        }
        System.out.println(ret);
    }*/
}